// API测试脚本
// 用于验证新API端点是否能正常工作

async function testAPIs() {
    console.log("开始测试API端点...");
    
    // 测试阅读进度API
    try {
        console.log("\n1. 测试阅读进度API...");
        const progressResponse = await fetch('https://tqi.techlinkpets3d.com/api/daka/userprogress');
        console.log("阅读进度API状态:", progressResponse.status);
        console.log("阅读进度API状态文本:", progressResponse.statusText);
        console.log("阅读进度API Content-Type:", progressResponse.headers.get('content-type'));
        
        const responseText = await progressResponse.text();
        console.log("阅读进度API响应内容长度:", responseText.length);
        console.log("阅读进度API响应内容前200字符:", responseText.substring(0, 200));
        
        if (progressResponse.ok) {
            try {
                const progressData = JSON.parse(responseText);
                console.log("阅读进度API响应:", JSON.stringify(progressData, null, 2));
            } catch (parseError) {
                console.log("阅读进度API JSON解析错误:", parseError.message);
            }
        } else {
            console.log("阅读进度API请求失败，状态码:", progressResponse.status);
        }
    } catch (error) {
        console.log("阅读进度API错误:", error.message);
    }
    
    // 测试打卡记录API
    try {
        console.log("\n2. 测试打卡记录API...");
        const recordResponse = await fetch('https://tqi.techlinkpets3d.com/api/daka/daka_record');
        console.log("打卡记录API状态:", recordResponse.status);
        console.log("打卡记录API状态文本:", recordResponse.statusText);
        console.log("打卡记录API Content-Type:", recordResponse.headers.get('content-type'));
        
        const responseText = await recordResponse.text();
        console.log("打卡记录API响应内容长度:", responseText.length);
        console.log("打卡记录API响应内容前200字符:", responseText.substring(0, 200));
        
        if (recordResponse.ok) {
            try {
                const recordData = JSON.parse(responseText);
                console.log("打卡记录API响应:", JSON.stringify(recordData, null, 2));
            } catch (parseError) {
                console.log("打卡记录API JSON解析错误:", parseError.message);
            }
        } else {
            console.log("打卡记录API请求失败，状态码:", recordResponse.status);
        }
    } catch (error) {
        console.log("打卡记录API错误:", error.message);
    }
    
    console.log("\nAPI测试完成。");
}

// 运行测试
testAPIs();